const EventEmitter = require('events');

class Dog extends EventEmitter {
    constructor(name, energy) {
        super();
        this.name = name;
        this.energy = energy;
    }

    bark() {
        if (this.energy > 0) {
            console.log(`${this.name} barked! energy: ${this.energy}`);
            this.energy--;
        }
    }
}

module.exports = Dog;